<?php $cs = Yii::app()->clientScript;
$cs->registerScriptFile(
$this->module->assetsUrl.'/js/xheditor/xheditor-1.1.12-zh-cn.min.js'
);
$this->breadcrumbs = array(
	'All tables' => array('index'),
	$table_name,
);
$cs->registerCssFile($this->module->assetsUrl.'/syntax/styles/shCoreDefault.css');
$cs->registerScriptFile($this->module->assetsUrl.'/syntax/scripts/shCore.js');
$cs->registerScriptFile($this->module->assetsUrl.'/syntax/scripts/shBrushSql.js');
?>
<script type="text/javascript">SyntaxHighlighter.all();</script>
<div class='detail-info'></div>
<div id='pic'>图例：<span class='del'>删除</span> <span class='ins'>修改/新增</span>
&nbsp;&nbsp;&nbsp;操作：<a href='javascript:;' id='all-close'>[全部收起]</a>
<a href='javascript:;' id='all-open'>[全部展开]</a>
<a href='<?php echo $this->createUrl('refresh', array('table_name'=>$table_name))?>' id='all-open'>[刷新]</a>
</div>
<?php $form = $this->beginWidget('CActiveForm', array(
	'action' => $this->createUrl($this->action->id, array('table_name'=>$table_name)),
	'method' => 'get',
))?>
<table class='detail mgb10'>
	<tr class='title'><td colspan=999><i>Search by conditions</i></td></tr>
	<tr>
		<th width=90><?php echo $form->label($model, 'begin_time')?>：</th>
		<td width=370>
		<?php $this->widget('lib.widgets.my97date.CMy97DatePicker',array(
			'model'=>$model,
			'attribute'=>'begin_time',
			'options' => array(
				'lang' => 'en',
				'dateFmt' => 'yyyy-MM-dd HH:mm:ss',
			),
			'htmlOptions' => array(
				'class'=>'bh-input',
			),
		));  
		?>
		<?php echo $form->label($model, 'end_time')?>
		<?php $this->widget('lib.widgets.my97date.CMy97DatePicker',array(
			'model'=>$model,
			'attribute'=>'end_time',
			'options' => array(
				'lang' => 'en',
				'dateFmt' => 'yyyy-MM-dd HH:mm:ss',
			),
			'htmlOptions' => array(
				'class'=>'bh-input',
			),
		)); 
		?>
		<td><?php echo CHtml::submitButton('Submit', array(
			'class' => 'pn',
			'style' => 'width:100px',
		))?></td>
	</tr>
</table>

<?php $this->endWidget()?>
<?php $index=1;$max=count($data->data)?>
<?php foreach($data->data as $one):?>
<div class='upgrade-item<?php if($index++ == $max) echo ' upgrade-item-last'?>'>
	<div class='upgrade-title'>
		<?php echo CHtml::value($one, 'author')?> 
		updated by 
		<?php echo CHtml::value($one, 'create_time')?>
		<span class='collapsed collapsed-no'></span>
	</div>
	<div class='upgrade-content'>
		<div class='upgrade-diff'>
			<div class='upgrade-content-navi'>
				<ul>
					<li class='hover' item='diff'><a href='javascript:;'>DIFF</a></li>
					<li item='sql'><a href='javascript:;'>SQL</a></li>
				</ul>
			</div>
			<div class='upgrade-content-wrapper'>
				<pre class='item' item='diff'><?php echo $one->diff_last?></pre>
				<div class='item' item='sql' style='display:none'>
					<pre class='brush: sql;'><?php echo $one->sql?></pre>
				</div>
			</div>
		</div>
		
		<div class='upgrade-diff'>
			<div class='upgrade-content-navi'>
				<ul>
					<li class='hover' item='remark'><a href='javascript:;'>REMARK</a></li>
					<li item='remark-edit'><a href='javascript:;'>[EDIT]</a></li>
				</ul>
			</div>
			<div class='upgrade-content-wrapper'>
				<div class='item upgrade-remark' item='remark'>
					<div class='upgrade-remark-content'>
						<?php echo CHtml::decode($one->remark ? $one->remark : '<i>(还未添加任何备注信息)</i>')?>
					</div>
				</div>
				<div class='item hide' item='remark-edit'>
					<?php $form = $this->beginWidget('CActiveForm', array(
						'method'=>'post',
						'action'=>$this->createUrl('updateRemark', array(
							'id' => $one->id,
						)),
					))?>
					<?php echo $form->textArea($one, 'remark', array(
						'class' => 'remark-textarea',
						'style' => 'height:114px',
					))?>
					<?php $this->endWidget()?>
					<div class='mgb10'>
						<a class='remark-form-submit' href='javascript:;'>[提交]</a>
					</div>
				</div>
			</div>
		</div>
		<div style='clear:both'></div>
	</div>
</div>
<?php endforeach?>
<div class='pager'>
	<?php $this->widget('CLinkPager', array(
		'pages' => $data->pagination,
		'cssFile' => false,
	))?>
</div>
<script>
$('.remark-textarea').xheditor({tools:'mini'});
$('.collapsed').click(function() {
	$this = $(this);
	if($this.hasClass('collapsed-yes')) {
		$(this).addClass('collapsed-no')
			.removeClass('collapsed-yes')
			.parent()
				.siblings()
				.show();
	} else {
		$(this).addClass('collapsed-yes')
			.removeClass('collapsed-no')
			.parent()
				.siblings()
				.hide();
	}
	
});
$('.remark-form-submit').click(function() {
	$(this).parent().siblings('form').submit();
})
$('#all-close').click(function() {
	$('.collapsed').removeClass('collapsed-yes').addClass('collapsed-no').click();
})
$('#all-open').click(function() {
	$('.collapsed').removeClass('collapsed-no').addClass('collapsed-yes').click();
})
$('.upgrade-content-navi li').click(function(){
	$this = $(this);
	$this.siblings().removeClass('hover').end().addClass('hover');
	itemName = $this.attr('item');
	$wrapper = $this.parent().parent().siblings('.upgrade-content-wrapper');
	$wrapper.find('.item[item='+itemName+']').show().siblings().hide();
})
</script>


